<template>
    <div>
      <div class="me_header">
        <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
        <span>视频</span>
        <img :src="'./static/lyl/san.png'" alt="">
      </div>
      <!--<video :src="'./static/video/video.mp4'" controls width="100%" :poster="'./static/lyl/photo1.png'"></video>-->
      <ul class="v_ul">
        <li @click="playVideo(item)" v-for="(item,index) in photoDat" :key="index">
          <img :src="item.thumb" alt="">
          <p>{{item.video_title}}</p>
        </li>
      </ul>

      <div class="m_footer">
        <span>分享</span>
        <span @click="follow()">{{status?'已关注':'关注'}}</span>
      </div>

      <transition name="van-slide-right">
        <div v-show="visible" class="tran_right">{{Fade}}</div>
      </transition>
    </div>
</template>

<script>
  import * as search from "../../../api/search.js"
    export default {
      name: "MeVideo",
      data(){
        return {
          Fade:'',
          visible:false,
          status:0,
          photoDat:[]
        }
      },
      mounted(){
        let par = {uid:this.$route.query.id,user_id:this.$store.state.user_id};
        search.userVideo(par).then(res=>{
          console.log('视频',res);
          this.photoDat = res.data;
          this.status = res.status
        })
      },
      methods:{
        playVideo(item){
          this.$router.push('/video2/'+item.id+'/'+item.active_id)
        },
        bac(){
          history.go(-1)
        },
        follow(){
          if (this.status==0){
            this.status = 1;
            let flow = {follow_id:this.$route.query.id,user_id:this.$store.state.user_id,status:1};
            search.follow(flow).then(res=>{
              console.log(res);
              this.visible = true;
              this.Fade = res.msg;
              setTimeout(() => {
                this.visible = false;
              }, 500);
            });
            search.followed(flow).then(res=>{
              console.log(res);
            })
          } else{
            this.status = 0;
            let flow = {follow_id:this.$route.query.id,user_id:this.$store.state.user_id,status:0};
            search.follow(flow).then(res=>{
              console.log(res);
              this.visible = true;
              this.Fade = res.msg;
              setTimeout(() => {
                this.visible = false;
              }, 500);
            });
            search.followed(flow).then(res=>{
              console.log(res);
            })
          }
        }
      }
    }
</script>

<style scoped>
  .me_header{
    border-bottom: 2px solid #dcdcdc;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
  }
  .me_header img:nth-child(1){
    width: 25px;
    height: 40px;
  }
  .me_header span{
    font-size: 32px;
  }
  .me_header img:nth-child(3){
    align-self: center;
    width: 60px;
  }

  .v_ul{
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
  }
  .v_ul li{
    position: relative;
    box-sizing: border-box;
    width: 50%;
    height: 300px;
    padding: 0 20px 20px 0;
  }
  .v_ul li:nth-child(2n+2){
    padding-right: 0;
  }
  .v_ul li img{
    width: 100%;
    height: 100%;
  }
  .v_ul li p{
    position: absolute;
    left: 20px;
    bottom: 20px;
    font-size: 32px;
    color: #fff;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }

  .m_footer{
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 80px;
    display: flex;
  }
  .m_footer span{
    font-size: 32px;
    background: #d8d8d8;
    width: 50%;
    height: 100%;
    line-height: 80px;
    text-align: center;
    border: 2px solid #dcdcdc;
  }
  .m_footer span:nth-child(2){
    background: #cbcbcc;
  }

  .tran_right{
    width: 220px;
    height: 60px;
    border-radius: 10px;
    text-align: center;
    line-height: 60px;
    font-size: 30px;
    top: 50%;
    left: 50%;
    position: fixed;
    background: rgba(0,0,0,0.6);
    color: #fff;
  }
</style>
